#!/usr/bin/ruby
require 'rubygems'
require 'ruby-debug'
require 'rexml/document'

class XmlParse

  attr_accessor :document
  
  def initialize(fname)
      xml = File.read(fname)
      @document = REXML::Document.new(xml)
  end
  
  def getparams
    
    res = {}
    hostname = REXML::XPath.match(@document.root, "//r:smconfig/r:hostname", "r" => "")
    res["hostname"] = hostname[0].text
    user = REXML::XPath.match(@document.root, "//r:smconfig/r:user", "r" => "")
    res["user"] = user[0].text
    pass = REXML::XPath.match(@document.root, "//r:smconfig/r:pass", "r" => "")
    res["pass"] = pass[0].text
    dbname = REXML::XPath.match(@document.root, "//r:smconfig/r:dbname", "r" => "")
    res["dbname"] = dbname[0].text
    return(res)
    
  end
  

end
